import util from './util';
import qs from 'qs';
import Config from '../config/config'
import $ from 'jquery'

const ajaxUrl = Config.env === 'development' ?
  'http://www.stu.com/index.php/Api/' :
  Config.env === 'production' ?
  '/index.php/Api/' :
  'http://www.stu.com/index.php/Api/';

let Service = {}
Service.$$path = {
  wxConfig: '/Tool/get_wx_config',
  // config: '/Config/config',
  authUrl: '/OfficialUser/auth_url',
  userInfo: '/OfficialUser/info',
  // login: '/OfficialUser/login',


  banner: '/Slide/lists',
  articleTerms: '/Nav/terms',
  indexArticle: '/Content/getIndex',
  articles: '/Content/lists',
  // detail: '/Content/detail',
  articleDetail: '/Content/detail',
  about: '/Tool/about',
  help: '/Tool/help',
  visit: '/Visit/visit',
  bindUid: '/OfficialUser/bind_uid',
  getValidCode: '/Tool/fetchCode',
  verifyCode: '/Tool/verifyCode',
  isBindPhone: '/OfficialUser/isBindPhone',
  bindPhone: '/OfficialUser/bindPhone',
  getPhoneNumber: '/OfficialUser/getPhoneNumber',

  saveQiniuPicture: '/Tool/saveQiniuPicture', //七牛上传
  saveQiniuFile: '/Tool/saveQiniuFile', //七牛上传
  uptoken: '/Tool/uptoken',


  // h5 支付
  // h5Pay: '/Order/pay_url',
    H5Pay : '/Order/pay',



  history: '/History/history', // 记录

  //提现
  withdraw: '/Income/withdraw',
  incomeDetail: '/Income/detail',
  incomeHistory: '/Income/history',


  recharge: '/Recharge/recharge', // 充值
  rechargePay: '/Recharge/pay', // 充值支付成功
  rechargeQuery: '/Recharge/query',

  printAttr: '/Print/getPageSize',
  fileList: '/File/lists', // 文件列表
  file: '/File/file', // 文件列表
  bindLogin: '/OfficialUser/bind_login',
  
  address: '/OfficialUser/address',


            banner: '/Slide/lists',
            nav: '/Nav/lists',
            board: '/Board/lists',
            loadHot: '/Content/loadHot',
            hotCategory: '/Shop/hotCategory',
            category: '/Shop/category',
            topics: '/Topic/topic',
            flashsaleNewest: '/FlashSale/newest',
            flashsale: '/FlashSale/flashsale',
            setNotify: '/FlashSale/setNotify',
            checkFlashSaleLimit: '/FlashSale/check_limit',
            classify: '/Products/classify',
            goods: '/Products/product',
            recommend: '/Products/recommend',
            productDetail: '/Products/detail',
            tuanOrderDetail: '/TuanOrder/tuanDetail',
            book: '/Book/get',
            batch: '/Book/batch',
            cart: '/Cart/cart',
            address: '/Address/address',
            checkAddress: '/Address/checkAddress',
            order: '/Order/order',
            tuanOrder: '/TuanOrder/order',
            flashSaleOrder: '/FlashSaleOrder/order',
            articleTerms: '/Nav/terms',
            articles: '/Content/lists',
            articleDetail: '/Content/detail',
            pay: '/Order/pay',
            tuanPay: '/TuanOrder/Pay',
            payOk: '/Order/payOk',
            payTuanOk: '/TuanOrder/payOk',

            isBindPhone: '/OfficialUser/isBindPhone',
            bindPhone: '/OfficialUser/bindPhone',
            getPhoneNumber: '/OfficialUser/getPhoneNumber',

            shop: '/Shop/shop',
            shopConfig: '/Shop/config',
            detailPoster: '/Retail/detailPoster',
            //提现
            summary: '/Income/summary',
            withdraw: '/Income/withdraw',
            incomeDetail: '/Income/detail',
            incomeHistory: '/Income/history',
            updateInfo: '/OfficialUser/updateInfo',
            getAccessToken: '/Tool/getAccessToken',
            getUserInfo: '/OfficialUser/getUserInfo',
            recordLocation: '/Location/record',
            // config: '/Retail/config',
            checkRetail: '/Retail/check',
            retailUser: '/Retail/user',
            retailIndex: '/Retail/index',
            retailLog: '/Retail/log',
            retailOrder: '/Retail/order',
            retailUserBind: '/Retail/bind',
            bindServicerQrcode: '/Retail/get_qrcode',
            getFavorList: '/favor/lists',
            favor: '/favor/add',
            unfavor: '/favor/del',
            //会员卡、优惠券
            card: '/Card/card', //会员卡配置等
            cardMember: '/Card/member', //会员卡
            recharge: '/Recharge/recharge', // 充值
            rechargePay: '/Recharge/pay', // 充值支付成功
            history: '/Member/history', // 记录
            //优惠券 
            coupon: '/Coupon/coupon',
            couponList: '/Coupon/lists',
            voucher: '/Voucher/voucher',
            doSign: '/Voucher/dosign',
            availibleList: '/Coupon/availible',
            setSnCode: '/Coupon/set_sn_code',
            setVoucherSnCode: '/Voucher/set_sn_code',
            // 商品评价
            comment: '/Comment/comment',
            commentList: '/Comment/list',
            // socket通信
            bindSocket: '/OfficialUser/bindSocket',
            weixinMessage: '/WeixinMessage/msg',
            replyText: '/WeixinMessage/replyText',
            replyImage: '/WeixinMessage/replyImage',
            saveQiniuPicture: '/Tool/saveQiniuPicture', //七牛上传
            shipperInfo: '/Order/shipperInfo',
            notice: '/Notice/notice',

            // 云联惠
            ylh: '/Ylh/ylh',


            //自己瞎写

            search            : 'Book/search',                // 搜索接口 参数k
            menu              : 'Book/lists',                 // 获取全部导航
            index             : 'Book/index',                 // 获取首页数据
            chapter           : 'Book/chapter',               // 获取文章列表 参数id 栏目id(parent != 0)
            detail            : 'Book/detail',                // 获取详细详细 参数id 栏目id(parent != 0)
            login             : 'Book/login',                 // 登陆。参数username password
            register          : 'Book/register',              // 注册。参数email, password, rpassword, mobile,
            checkLogin        : 'Book/check_login',           // 暂时没有
            logout            : 'Book/logout',                // 暂时没有
            singleCategory    : 'Book/single_category',       // 获取单个栏目 参数id 栏目id(parent != 0)
            getDataByStatus   : 'Book/get_data_by_status',    // 获取数据根据model和status 参数model, status, p, limit
            addClickNum       : 'Book/add_click_num',         // 增加点击数量
            getSubCategory    : 'Book/get_sub_category',      // 获取子栏目 参数cat_id, p, limit, status 栏目id(parent=0)
            signIn            : 'Book/sign_in',               // 自动登陆返回用户基本信息
            getConfig         : 'Book/get_config',            // 获取用户更多的配置
            createdVerify     : 'Book/created_verify',        // 创建验证码
            checkVerify       : 'Book/check_verify',          // 校验验证码
            addBook           : 'Book/add_book',              // 添加收藏 参数id 栏目id(parent != 0)
            cancelByModel     : 'Book/cancel_by_model',       // 取消收昂 参数id 栏目id(parent != 0)
            getComment        : 'Book/get_comment',           // 获取评论 参数id, p, limit, status 栏目id(parent != 0)
            bookComment       : 'Book/book_comment',          // 发表评论 参数id, conntent, title 栏目id(parent != 0)
            perfect           : 'Book/perfect',               // 完善资料 参数avatar address nickname truename hoibbs sex personality_name
            getPostContent    : 'Book/get_post_content',      // 获取付费文章 参数文章id
            getYourLikes      : 'Book/get_your_likes',        // 获取随机你喜欢的数据 没登陆测随机返回       
            getShop           : 'Book/shop',                  // 获取商城页面数据  
            cart              : 'Book/cart',                  // 购物车(post, get, put)  
            uploadPic         : 'home/File/uploadPicture',    // 服务端上传图片
            address           : 'Book/address',               // 地址i系列接口
            queryBook         : 'Book/query_book',            // 查询是否收藏该商品 参数pid type
  
            // order
            order             : 'Order/order',                // 订单系列
            query             : 'Order/query',               // 检查订单




            //学校系统
            student           : 'student/index',
            stuLogin          : 'student/login',
            signIn            : 'student/sign_in'
}
// Service.getRequest = function(url, param = {}) {
//   let u = ajaxUrl + url

//   // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
//   let publicid = util.getCookieSync('publicid') || Config.publicid
//   if (!param.publicid && publicid)
//     param.publicid = publicid
//   // console.log(param)
  

//   return $.get(u, qs.stringify(param)).done(res => {
//     return new Promise((resolve, reject) => {
//       resolve(res.data)
//     })
//   })
// }

// Service.postRequest = function(url, param = {}) {
//    let u = ajaxUrl + url

//   // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
//   // console.log(param)
//   // console.log(util.ajax)
//   let publicid = util.getCookieSync('publicid') || Config.publicid
//   // console.log(publicid)
//   if (!param.publicid && publicid)
//     param.publicid = publicid

//   // return util.ajax.post(url, qs.stringify(param)).then(res => {
//   //   return new Promise((resolve, reject) => {
//   //     resolve(res.data)
//   //   })
//   // })

//   return $.post(u, qs.stringify(param)).done(res => {
//     return new Promise((resolve, reject) => {
//       resolve(res.data)
//     })
//   })

// }


Service.getRequest = function(url, param = {}) {

  // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
  let publicid = util.getCookieSync('publicid') || Config.publicid
  if (!param.publicid && publicid)
    param.publicid = publicid  
  // console.log(param)

  return util.ajax.get(url, { params: param }).then(res => {
    // console.log(res)
    return new Promise((resolve, reject) => {
      resolve(res.data)
    })
  })
}

Service.postRequest = function(url, param = {}) {

  // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
  // console.log(param)
  // console.log(util.ajax)
  let publicid = util.getCookieSync('publicid') || Config.publicid
  // console.log(publicid)
  if (!param.publicid && publicid)
    param.publicid = publicid
  return util.ajax.post(url, qs.stringify(param)).then(res => {
    return new Promise((resolve, reject) => {
      resolve(res.data)
    })
  })
}

Service.putRequest = function(url, param = {}) {
  let publicid = util.getCookieSync('publicid') || Config.publicid
  if (!param.publicid && publicid)
    param.publicid = publicid
  // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
  return util.ajax.put(url, qs.stringify(param)).then(res => {
    return new Promise((resolve, reject) => {
      resolve(res.data)
    })
  })
}

Service.deleteRequest = function(url, param = {}) {
  let publicid = util.getCookieSync('publicid') || Config.publicid
  if (!param.publicid && publicid)
    param.publicid = publicid
  // util.ajax.defaults.headers.SESSION = util.getStorageSync('session') || '';
  return util.ajax.delete(url, qs.stringify(param)).then(res => {
    return new Promise((resolve, reject) => {
      resolve(res.data)
    })
  })
}

// 我的书城 接口 （start）

/* get 请求 */
Service.getDetail             = function(params) {
  return this.getRequest(this.$$path.detail, params)
}
Service.getChapter            = function(params) {
  return this.getRequest(this.$$path.chapter, params)
}
Service.getSearch             = function(params) {
  return this.getRequest(this.$$path.search, params)
}
Service.getMenu               = function(params) {
  return this.getRequest(this.$$path.menu, params)
}
Service.getIndex              = function(params) {
  return this.getRequest(this.$$path.index, params)
}
Service.getSingleCategory     = function(params) {
  return this.getRequest(this.$$path.singleCategory, params)
}
Service.getDataByStatus       = function(params) {
  return this.getRequest(this.$$path.getDataByStatus, params)
}
Service.getSubCategory        = function(params) {
  return this.getRequest(this.$$path.getSubCategory, params)
}
Service.getComment            = function(params) {
  return this.getRequest(this.$$path.getComment, params)
}
Service.getPostContent        = function(params) {
  return this.getRequest(this.$$path.getPostContent, params)
}
Service.getPerfect            = function(params) {
  return this.getRequest(this.$$path.perfect, params)
}
Service.getYourLikes          = function(params) {
  return this.getRequest(this.$$path.getYourLikes, params)
}
Service.getShop               = function(params) {
  return this.getRequest(this.$$path.getShop, params)
}
Service.queryBook             = function(params) {
  return this.getRequest(this.$$path.queryBook, params)
}

// 地址
Service.GAddress              = function(params) {
  return this.getRequest(this.$$path.address, params)
}
Service.AAddress              = function(params) {
  return this.postRequest(this.$$path.address, params)
} 
Service.DAddress              = function(params) {
  return this.deleteRequest(this.$$path.address, params)
}

// 订单系列
Service.GOrder                = function(params) {
  return this.getRequest(this.$$path.order, params)
}
Service.AOrder                = function(params) {
  return this.postRequest(this.$$path.order, params)

}
Service.DOrder                = function(params) {
  return this.deleteRequest(this.$$path.order, params)
}
Service.query                 = function(params) {
  return this.postRequest(this.$$path.query, params)
}


// 学校系列
Service.GStudent               = function (params) {
  return this.getRequest(this.$$path.student, params)
}

Service.PStudent               = function (params) {
  return this.postRequest(this.$$path.student, params)
}

Service.DStudent               = function (params) {
  return this.deleteRequest(this.$$path.student, params)
}

Service.stuLogin               = function (params) {
  return this.postRequest(this.$$path.stuLogin, params)
}

Service.signIn                 = function (params) {
  return this.postRequest(this.$$path.signIn, params)
}






/* post 请求 */
Service.login                 = function(params) {
  return this.postRequest(this.$$path.login, params)
}
Service.register              = function(params) {
  return this.postRequest(this.$$path.register, params)
}
Service.checkLogin            = function(params) {
  return this.postRequest(this.$$path.checkLogin, params)
}
Service.logout                = function(params) {
  return this.postRequest(this.$$path.logout, params)
}
Service.addClickNum           = function(params) {
  return this.postRequest(this.$$path.addClickNum, params)
}
Service.signIn                = function(params) {
  return this.postRequest(this.$$path.signIn, params)
}
Service.getConfig             = function(params) {
  return this.postRequest(this.$$path.getConfig, params)
} 
Service.createdVerify         = function(params) {
  return this.postRequest(this.$$path.createdVerify, params)
}
Service.checkVerify           = function(params) {
  return this.postRequest(this.$$path.checkVerify, params)
}
Service.addBook               = function(params) {
  return this.postRequest(this.$$path.addBook, params)
}
Service.cancelByModel         = function(params) {
  return this.postRequest(this.$$path.cancelByModel , params)
}
Service.bookComment           = function(params) {
  return this.postRequest(this.$$path.bookComment , params)
}
Service.perfect               = function(params) {
  return this.postRequest(this.$$path.perfect , params)
} 

// 多功能
Service.getCarts              = function(params) {
  return this.getRequest(this.$$path.cart, params)
}

Service.postCart             = function(params) {
  return this.postRequest(this.$$path.cart, params)
}



// 我的书城 接口 (end)


Service.getPrintAttr = function(params) {
  return this.postRequest(this.$$path.printAttr, params)
}
// Service.getIndex = function(params) {
//   return this.getRequest(this.$$path.indexArticle, params)
// }
// Service.login = function(params) {
//   return this.postRequest(this.$$path.login, params)
// }
Service.bindPhone = function(params) {
  return this.postRequest(this.$$path.bindPhone, params)
}
Service.isBindPhone = function(params) {
  return this.getRequest(this.$$path.isBindPhone, params)
}
Service.getPhoneNumber = function(params) {
  return this.getRequest(this.$$path.getPhoneNumber, params)
}
Service.verifyCode = function(params) {
  return this.postRequest(this.$$path.verifyCode, params)
}

Service.getValidCode = function(params) {
  return this.getRequest(this.$$path.getValidCode, params)
}

Service.getTerms = function(params) {
  return this.getRequest(this.$$path.articleTerms, params)
}
Service.articles = function(params) {
  return this.getRequest(this.$$path.articles, params)
}
Service.getBanners = function(params) {
  return this.getRequest(this.$$path.banner, params)
}
// Service.getDetail = function(params) {
//   //return this.getRequest(`${this.$$path.goods}/${id}`)
//   return this.getRequest(this.$$path.detail, params)
// }
Service.about = function() {
  return this.getRequest(this.$$path.about)
}
Service.help = function() {
  return this.getRequest(this.$$path.help)
}
Service.articles = function(params) {
  return this.getRequest(this.$$path.articles, params)
}
Service.articleDetail = function(params) {
  return this.getRequest(this.$$path.articleDetail, params)
}

Service.getWxConfig = function(params) {
  return this.getRequest(this.$$path.wxConfig, params);
}



Service.getAuthUrl = function(params) {
  return this.getRequest(this.$$path.authUrl, params);
}



Service.getUserInfo = function(params) {
  return this.getRequest(this.$$path.userInfo, params);
}


Service.getGlobalConfig = function(params) {
  return this.getRequest(this.$$path.config, params)
}



// 获取模板列表
Service.getUptoken = function(params) {
  return this.getRequest(this.$$path.uptoken, params)
}

// 获取模板列表
Service.getHistoryList = function(params) {
  return this.getRequest(this.$$path.history, params)
}


// 保存七牛图片数据到数据库
Service.saveQiniuPicture = function(params) {
  return this.postRequest(this.$$path.saveQiniuPicture, params)
}
// 保存七牛文件数据到数据库
Service.saveQiniuFile = function(params) {
  return this.postRequest(this.$$path.saveQiniuFile, params)
}



Service.withdraw = function(params) { //获取城市
  return this.postRequest(this.$$path.withdraw, params)
}

Service.rechargePay = function(params) {
  return this.postRequest(this.$$path.rechargePay, params)
}

Service.rechargeQuery = function(params) {
  return this.postRequest(this.$$path.rechargeQuery, params)
}

Service.recharge = function(params) {
  return this.postRequest(this.$$path.recharge, params)
}

Service.getRechargeCondition = function(params) {
  return this.getRequest(this.$$path.recharge, params)
}


Service.getWithdrawHistory = function(params) { //获取城市
  return this.getRequest(this.$$path.withdraw, params)
}

Service.getIncomeDetail = function(params) { //获取城市
  return this.getRequest(this.$$path.incomeDetail, params)
}

Service.getIncomeHistory = function(params) { //获取城市
  return this.getRequest(this.$$path.incomeHistory, params)
}
Service.getSubscribeQrcode = function(params) { //获取城市
  return this.getRequest(this.$$path.bindLogin, params)
}
Service.checkSubscribe = function(params) { //获取城市
  return this.postRequest(this.$$path.bindLogin, params)
}


Service.getAddress = function(params) { //获取城市
  return this.getRequest(this.$$path.address, params)
}

Service.getNoticeList= function (params) {
    return this.getRequest(this.$$path.notice, params)
}
Service.getShipperInfo= function (params) {
    return this.getRequest(this.$$path.shipperInfo, params)
}
Service.bindRetailRelationShip= function (params) {
    return this.postRequest(this.$$path.retailUserBind, params)
}
Service.saveRetailUser= function (params) {
    return this.postRequest(this.$$path.retailUser, params)
}
Service.recordScene= function (params) {
    return this.postRequest(this.$$path.retailLog, params)
}
Service.getRetailIndex= function (params) {
    return this.getRequest(this.$$path.retailIndex, params)
}
Service.getRetailUser= function (params) {
    return this.getRequest(this.$$path.retailUser, params)
}
Service.getRetailOrder= function (params) {
    return this.getRequest(this.$$path.retailOrder, params)
}
Service.checkRetail= function (params) {
    return this.getRequest(this.$$path.checkRetail, params)
}
Service.getRetailUserList= function (params) {
    return this.getRequest(this.$$path.retailUser, params)
}
Service.delRetailRelationShip= function (params) {
    return this.deleteRequest(this.$$path.retailUser, params)
}
Service.myCard= function (params) {
    return this.getRequest(this.$$path.card, params)
}
Service.getCardInfo= function (params) {
    return this.getRequest(this.$$path.cardMember, params)
}
Service.writeCardInfo= function (params) {
    return this.postRequest(this.$$path.cardMember, params)
}
Service.setVoucherSnCode= function (params) {
    return this.postRequest(this.$$path.setVoucherSnCode, params)
}
Service.setSnCode= function (params) {
    return this.postRequest(this.$$path.setSnCode, params)
}
Service.doSign= function (params) {
    return this.postRequest(this.$$path.doSign, params)
}
Service.getAvailibleList= function (params) {
    return this.getRequest(this.$$path.availibleList, params)
}
Service.getCouponDetail= function (params) {
    return this.getRequest(`${this.$$path.coupon}/id/${params.id}`, params);
}
Service.getCouponList= function (params) {
    return this.getRequest(this.$$path.couponList, params)
}
Service.addCoupon= function (params) {
    return this.post(this.$$path.coupon, params)
}
Service.rechargePay= function (params) {
    return this.postRequest(this.$$path.rechargePay, params)
}
Service.recharge= function (params) {
    return this.postRequest(this.$$path.recharge, params)
}
Service.getRechargeCondition= function (params) {
    return this.getRequest(this.$$path.recharge, params)
}
Service.locateCampus= function (params) {
    return this.getRequest(this.$$path.locateCampus, params)
}
Service.getGlobalConfig= function (params) {
    return this.getRequest(this.$$path.config, params)
}
Service.recordLocation= function (params) {
    return this.getRequest(this.$$path.recordLocation, params);
}
Service.updateUserInfo= function (params) {
    return this.postRequest(this.$$path.updateInfo, params)
}
Service.getAccessToken= function (params) {
    return this.getRequest(this.$$path.getAccessToken, params)
}
Service.withdraw= function (params) { //获取城市
    return this.postRequest(this.$$path.withdraw, params)
}
Service.getWithdrawHistory= function (params) { //获取城市
    return this.getRequest(this.$$path.withdraw, params)
}
Service.getIncomeSumary= function (params) { //获取城市
    return this.getRequest(this.$$path.summary, params)
}
Service.getIncomeDetail= function (params) { //获取城市
    return this.getRequest(this.$$path.incomeDetail, params)
}
Service.getIncomeHistory= function (params) { //获取城市
    return this.getRequest(this.$$path.incomeHistory, params)
}
Service.getHistoryList= function (params) {
    return this.getRequest(this.$$path.history, params)
}
Service.tapGood= function (params) {
    return this.postRequest(this.$$path.tapGood, params)
}
Service.addPost= function (params) {
    return this.postRequest(this.$$path.post, params)
}
Service.addPostComment= function (params) {
    return this.postRequest(this.$$path.postComment, params)
}
Service.getMomentsList= function (params) {
    return this.getRequest(this.$$path.momentsList, params)
}
Service.getMomentsDetail= function (params) {
    return this.getRequest(this.$$path.momentsDetail, params)
}
Service.getCampusList= function (params) {
    return this.getRequest(this.$$path.campusList, params)
}
Service.getBoard= function (params) {
    return this.getRequest(this.$$path.board, params)
}
Service.getQrcode= function (params) {
    return this.getRequest(this.$$path.qrcode, params)
}
Service.getUserQrcode= function (params) {
    return this.getRequest(this.$$path.userQrcode, params)
}
Service.wechatSignUp= function (params) {
    return this.postRequest(this.$$path.wechatSignUp, params)
}
// Service.wechatSignIn= function (params) {
//     return this.postRequest(this.$$path.wechatSignIn, params)
// }
Service.wechatDecryptData= function (params) {
    return this.postRequest(this.$$path.decryptData, params)
}
// Service.signIn= function (params) {
//     return this.postRequest(this.$$path.signIn, params)
// }
Service.signOut= function () {
    return this.postRequest(this.$$path.signOut)
}
// Service.login= function (params) {
//     return this.postRequest(this.$$path.login, params)
// }
Service.bindPhone= function (params) {
    return this.postRequest(this.$$path.bindPhone, params)
}
Service.isBindPhone= function (params) {
    return this.getRequest(this.$$path.isBindPhone, params)
}
Service.getPhoneNumber= function (params) {
    return this.getRequest(this.$$path.getPhoneNumber, params)
}
Service.verifyCode= function (params) {
    return this.postRequest(this.$$path.verifyCode, params)
}
Service.getValidCode= function (params) {
    return this.getRequest(this.$$path.getValidCode, params)
}
Service.getHelps= function (params) {
    return this.getRequest(this.$$path.help, params)
}
Service.loadHot= function (params) {
    return this.getRequest(this.$$path.loadHot, params)
}
Service.getTerms= function (params) {
    return this.getRequest(this.$$path.articleTerms, params)
}
Service.articles= function (params) {
    return this.getRequest(this.$$path.articles, params)
}
Service.articleDetail= function (params) {
    return this.getRequest(this.$$path.articleDetail, params)
}
Service.getBanners= function (params) {
    return this.getRequest(this.$$path.banner, params)
}
Service.getNav= function () {
    return this.getRequest(this.$$path.nav)
}
Service.getHotCategory= function () {
    return this.getRequest(this.$$path.hotCategory)
}
Service.getCategory= function (params) {
    return this.getRequest(this.$$path.category, params)
}
Service.checkFlashSaleLimit= function (params) {
    return this.getRequest(this.$$path.checkFlashSaleLimit, params)
}
Service.getFlashSaleNewest= function () {
    return this.getRequest(this.$$path.flashsaleNewest)
}
Service.getFlashSaleList= function () {
    return this.getRequest(this.$$path.flashsale)
}
Service.setNotify= function (params) {
    return this.getRequest(this.$$path.setNotify, params)
}
Service.getTopics= function (params) {
    return this.getRequest(this.$$path.topics, params)
}
Service.getProducts= function (params) {
    return this.getRequest(this.$$path.goods, params)
}
Service.getRecommend= function (params) {
    return this.getRequest(this.$$path.recommend, params)
}
Service.searchProducts= function (params) {
    return this.getRequest(this.$$path.goods, params)
}
Service.getClassify= function (params) {
    return this.getRequest(this.$$path.classify, params)
}
Service.getProductDetail= function (params) {
    return this.getRequest(this.$$path.productDetail, params)
}
Service.getTuanOrderDetail= function (params) {
    return this.getRequest(this.$$path.tuanOrderDetail, params)
}
Service.getCartByUser= function () {
    return this.getRequest(this.$$path.cart)
}
Service.addCartByUser= function (params) {
    return this.postRequest(this.$$path.cart, params)
}
Service.putCartByUser = function(id, params) {
    return this.putRequest(`${this.$$path.cart}/${id}`, params)
}
Service.delCartByUser= function (params) {
    return this.deleteRequest(`${this.$$path.cart}`, params)
}
Service.clearCartByUser= function () {
    return this.postRequest(`${this.$$path.cart}/clear`)
}
Service.deleteAddress= function (id, params) {
    return this.deleteRequest(`${this.$$path.address}/id/${id}`, params)
}
Service.postAddress= function (params) {
    return this.postRequest(this.$$path.address, params)
}
Service.checkAddress= function (params) {
    return this.postRequest(this.$$path.checkAddress, params)
}
Service.putAddress = function (id, params) {
    return this.putRequest(`${this.$$path.address}/id/${id}`, params)
}
Service.getDefalutAddress= function () {
    return this.getRequest(`${this.$$path.address}`, { default: 1 })
}
Service.getOrderList= function (params) {
    return this.getRequest(this.$$path.order, params)
}
Service.getTuanOrderList= function (params) {
    return this.getRequest(this.$$path.tuanOrder, params)
}
Service.getOrderDetail= function (id) {
    return this.getRequest(`${this.$$path.order}/id/${id}`, {
        id: id
    })
}
Service.getTuanDetail= function (id) {
    return this.getRequest(`${this.$$path.tuanOrder}/id/${id}`, {
        id: id
    })
}
Service.postOrder= function (params) {
    return this.postRequest(this.$$path.order, params)
}
Service.postTuanOrder= function (params) {
    return this.postRequest(this.$$path.tuanOrder, params)
}
Service.postFlashSaleOrder= function (params) {
    return this.postRequest(this.$$path.flashSaleOrder, params)
}
Service.putOrder =  function(id, params) {
    return this.putRequest(`${this.$$path.order}/id/${id}`, params)
}
Service.putTuanOrder=  function(id, params) {
    return this.putRequest(`${this.$$path.tuanOrder}/id/${id}`, params)
}
Service.refundOrder= function (params) {
    return this.deleteRequest(`${this.$$path.order}`, params)
}
Service.refundTuanOrder= function (params) {
    return this.deleteRequest(`${this.$$path.tuanOrder}`, params)
}
Service.deleteOrder=  function(id, params) {
    return this.deleteRequest(`${this.$$path.order}/id/${id}`)
}
Service.getApiParameters= function (params) {
    return this.postRequest(this.$$path.pay, params)
}
Service.getTuanPay= function (params) {
    return this.postRequest(this.$$path.tuanPay, params)
}
Service.payOk= function (params) {
    return this.postRequest(this.$$path.payOk, params)
}
Service.payTuanOk= function (params) {
    return this.postRequest(this.$$path.payTuanOk, params)
}
Service.commonPay= function (params) {
    return this.postRequest(this.$$path.commonPay, params)
}
Service.commonPayOk= function (params) {
    return this.postRequest(this.$$path.commonPayOk, params)
}
Service.about= function () {
    return this.getRequest(this.$$path.about)
}
Service.help= function () {
    return this.getRequest(this.$$path.help)
}
Service.getFavorList= function (params) {
    return this.getRequest(this.$$path.getFavorList, params)
}
Service.favor= function (params) {
    return this.getRequest(this.$$path.favor, params)
}
Service.unfavor= function (params) {
    return this.getRequest(this.$$path.unfavor, params)
}
Service.getCommentDetail= function (params) {
    return this.getRequest(`${this.$$path.comment}/id/${params.id}`, params)
}
Service.getCommentList= function (params) {
    return this.getRequest(this.$$path.commentList, params)
}
Service.addCommonComment= function (params) {
    return this.postRequest(this.$$path.comment, params)
}
Service.getShopList= function (params) {
    return this.getRequest(this.$$path.shop, params)
}
Service.getShopConfig= function (params) {
    return this.getRequest(this.$$path.shopConfig, params)
}
Service.getDetailPoster= function (params) {
    return this.getRequest(this.$$path.detailPoster, params)
}
Service.saveQiniuPicture= function (params) {
    return this.postRequest(this.$$path.saveQiniuPicture, params)
}


Service.H5Pay = function(params) {
  return this.postRequest(this.$$path.H5Pay, params)
}







export default Service